<?php
/***
 *Powered by 厦门元途
 *Copyright http:
 *Auther:YunMall zhang
 *Date:2008-11-7
 *Des:产品类别页面，已做缓存处理
 */
//=============================================
if(empty($_GET['m'])||empty($_GET['s']))
	die('forbiden;');
//------------------------------
$provinceid =$_GET['province'];
$cityid = $_GET['city'];
$areaid = $_GET['area'];
//=================================
 $get_province = $_GET['province'];
 $get_city = $_GET['city'];

if($get_province){
	$str_where = " and province = ".$get_province;
	$str_ad = " and province = ".$get_province;
	$wap_where = " and s.province = ".$get_province;
}
if($get_city){
	$str_where .= " and city = ".$get_city;
	$str_ad .= " and city = ".$get_city;
	$wap_where .= " and s.city = ".$get_city;
}
if($daid){
	$str_where .= " and areaid = ".getdistrictid($daid);
	$str_ad .= " and area = ".getdistrictid($daid);
}

if($config['temp']!='wap')
{
	//================================banner========================
	$b_sql="select * from ".ADVSCON." where group_id='1' and isopen=1  order by sort_num asc";
	$db->query($b_sql);
	$banner = $db->getRows();
	$tpl->assign("banner",$banner);

	//=======================猜您喜欢 为您推荐
	if(!empty($provinceid)){
		$like_where = " and provinceid='$provinceid' ";
	} else {
		$like_where = " and cityid='$get_city'";
	}
	$l_sql = "select * from ".CONFIG. " where `index`='like' and `type`='home' $like_where  ";
	$db->query($l_sql);
	$config['like'] = $db->fetchField(value);
	$h_sql = "select * from ".CONFIG. " where `index`='hot_sell' and `type` = 'home' $like_where ";
	$db->query($h_sql);
	$config['hot_sell'] = $db->fetchField(value);
	$type=array(
		array('id'=>$config['like'],'name'=>'猜您喜欢'),
		array('id'=>$config['hot_sell'],'name'=>'为您推荐'),
	);
	foreach($type as $key => $val){
		$ids = !empty(rtrim($val['id'],',')) ? rtrim($val['id'],',') : 0;

		$db->query("select * from ".SETMEAL." where id in($ids)");
		$type[$key]['product_list'] = $db->getRows();
	}
	$tpl->assign("type",$type);

	//================================================楼层数据================================================
	$cat_sql = "select * from ".PCAT." where isindex='1' and catid < 9999 and catid not in(1008,1009) ";
	$db->query($cat_sql);
	$category = $db->getRows();

	foreach($category as $key => $val){
		$po_sql = "select * from ".SETMEAL." where catid='{$val['catid']}' $str_where group by pid order by id desc limit 0,6 ";
		$db->query($po_sql);
		$po_list = $db->getRows();
		foreach($po_list as $k => $v){
			$exp = explode(',',$v['setmeal']);
			$po_list[$k]['prev_date'] = $exp[0];

		}
		$catid = $key + 1;
		$ad_sql = "select * from ".ADVSCON." where group_id = 4 and isopen = 1 and catid='$catid' ";
		$db->query($ad_sql);
		$ads = $db->fetchRow();
		$category[$key]['adv_pic_name'] = $ads['picName'];
		$category[$key]['adv_url'] = $ads['url'];
		$category[$key]['adv_name'] = $ads['name'];

		$category[$key]['list'] = $po_list;
	}
	//var_dump($category[0]);exit;
	$tpl->assign('category',$category);

} else {

	$b_sql="select * from ".ADVSCON." where group_id='17' and isopen=1 $str_ad order by sort_num asc";
	$db->query($b_sql);
	$banner = $db->getRows();
	$tpl->assign("banner",$banner);

	$h_sql = "select s.*,p.spot,p.pname,p.ftitle from ".SETMEAL." s left join ".PRO." p on s.pid=p.id where 1 $wap_where group by s.catid order by s.id desc limit 0,10";

	$db->query($h_sql);
	$hot = $db->getRows();
	$tpl->assign('hot',$hot);
	$a_sql = "select * from ".NEWSD." where ispass = '1' and classid = '1d' order by nid desc limit 0,6 ";
	$db->query($a_sql);
	$news = $db->getRows();
	$tpl->assign('news',$news);


}



$config['title'] = "官方一级文化演出票务网、100%官方正品、100%官方正价！";
//======================================

$tpl->assign("config",$config);

//------------------------------
$tpl->assign("current",'index');

include_once("footer.php");

//=============================================
$out=tplfetch("product_index.htm",NULL);
?>